// import Vue from 'vue';
import axios from 'axios';
// Vue.use(axios);

const api = axios.create({
	baseURL: 'http://kumanxuan1.f3322.net:8001',
	timeout: 1000,
});
// 请求拦截器
api.interceptors.request.use(
	function (config) {
		// 将token从localStorage中读取出来，设置为请求头
		config.headers['X-Nideshop-Token'] = localStorage.getItem('TOKEN')
		return config;
	},
	function (error) {
		// Do something with request error
		return Promise.reject(error);
	}
);
// 响应拦截
api.interceptors.response.use(
	(response) => {
		return response.data;
	},
	(err) => {
		console.log('响应有问题:', err);
		return Promise.reject(err);
	}
);

export default api;
